/*
Auhtor      : Pratibh Prakash
Company     : Fujitsu America
Created Date: 30 Sep-2009
Description : Trigger prevents insertion of Account record based on the User Profile 
			  but if Account record is inserted due to Lead conversion trigger allows 
			  the new Account to be inserted.
*/
trigger preventAccountCreateTrigger on Account (before insert) {
	Profile curUserProfile = [Select Name from Profile where Id =: UserInfo.getProfileId()];
	
	if(Label.IM_Admin_Profiles != null && !Label.IM_Admin_Profiles.contains(curUserProfile.Name)){//Checking current user profile with white listed profiles.
		for(Integer i=0; i<Trigger.new.size(); i++){
			if(Trigger.new[i].IM_Lead_Conversion_Flag__c != true){//Determining if Account insertion is from Lead Conversion Process. 
				Trigger.new[0].addError('Insufficient Privileges to create new Account');
			}
		}
	}
	
}